import org.molamil.acto.core.EventConstants;
import org.molamil.acto.core.Logger;
import org.molamil.acto.pages.master.AbstractLinkedMaster;
import org.molamil.acto.pages.master.PageMaster;
import org.molamil.acto.pages.master.PageMasterDelegate;

/**
 * <code>PageMaster</code> that uses linked <code>MovieClip</code>'s from the library as pages.
 *
 * @author Jorge Hernandez
 */
class org.molamil.acto.pages.master.LinkedPageMaster extends AbstractLinkedMaster implements PageMaster {
	
	
	// Properties
	
	private static var log:Logger = Logger.getLogger("LinkedPageMaster");
	
	private var pageMasterDelegate:PageMasterDelegate;	
	
	
	// Constructor
	
	public function LinkedPageMaster() {
		log.debug("Constructor");
		pageMasterDelegate = new PageMasterDelegate(this);
	}
	
	
	// Functions
	
	public function display():Void {
		
		log.info("display(), name = " + context.name);
		
		super.display();
		
		var eventObject:Object = {target: this, type: EventConstants.PAGE_DISPLAY};
		dispatchEvent(eventObject);
		
	}
	
	public function clear():Void {
		
		log.info("clear(), name = " + context.name);
		
		super.clear();
		
		var eventObject:Object = {target: this, type: EventConstants.PAGE_CLEAR};
		dispatchEvent(eventObject);
		
	}
	
	private function mcStateChangeListener(eventObject:Object):Void {
		
		super.mcStateChangeListener(eventObject);
		
		log.debug("mcStateChangeListener(), state = " + eventObject.state);
		
		pageMasterDelegate.mcStateChangeListener(eventObject);
		
	}
	
	
}